<template>
  <div class="tab-control">
    <div
      v-for="(item, index) in titles"
      :key="item"
      class="tab-item"
      :class="{ active: index === currentIndex }"
    >
      <span>{{ item }}</span>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      currentIndex: 0
    }
  },
  props: {
    titles: {
      type: Array,
      default() {
        return []
      }
    }
  }
}
</script>

<style scoped>
.tab-control {
  display: flex;
  font-size: 15px;
  text-align: center;
  height: 40px;
  line-height: 40px;
}
.tab-item {
  flex: 1;
}
.tab-item span {
  padding: 5px;
}
.active span {
  color: orangered;
  border-bottom: 3px solid orangered;
}
</style>
